package com.test.realcityalfa.frmwrk;

import java.util.List;

import android.app.ActivityManager;
import android.app.ActivityManager.RunningTaskInfo;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;

import com.actionbarsherlock.app.SherlockActivity;
import com.actionbarsherlock.view.MenuItem;
import com.test.realcityalfa.DashboardActivity;

public class BaseActivity extends SherlockActivity
{
	 public static boolean isApplicationGoingToBackground(final Context context) {

	         ActivityManager am = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
	         List<RunningTaskInfo> tasks = am.getRunningTasks(1);
	         if (!tasks.isEmpty()) {
	             ComponentName topActivity = tasks.get(0).topActivity;
	             if (!topActivity.getPackageName().equals(context.getPackageName())) {
	                 return true;
	             }
	         }

	         return false;
	     }

	/* (non-Javadoc)
	 * @see com.actionbarsherlock.app.SherlockActivity#onOptionsItemSelected(com.actionbarsherlock.view.MenuItem)
	 */
	@Override
	public boolean onOptionsItemSelected(MenuItem item) {		
		
		if(item.getItemId() == android.R.id.home)
		{
			startActivity(new Intent(getApplicationContext(), DashboardActivity.class).addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP));
		}
		return super.onOptionsItemSelected(item);
	}

	
	 

}
